/* ===================================================================
   库存管理模态框样式
   基于Apple Design System
   文件：inventory-modal.css
=================================================================== */

/* 库存管理模态框 */
.inventory-modal {
    width: 90vw;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.inventory-modal .modal-body {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 库存概览 */
.inventory-overview {
    padding: var(--spacing-6);
    border-bottom: 1px solid var(--separator-non-opaque);
    background-color: var(--system-background-secondary);
}

.inventory-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-4);
    min-width: 300px;
}

/* 库存管理标签页 */
.inventory-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 当前库存 */
.current-inventory {
    max-width: none;
}

.inventory-summary {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-6);
}

.summary-card {
    background-color: var(--system-background-secondary);
    border-radius: var(--radius-large);
    padding: var(--spacing-6);
    border: 1px solid var(--separator-non-opaque);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-4);
}

.summary-title {
    font-size: var(--font-size-headline);
    font-weight: var(--font-weight-semibold);
    color: var(--label-primary);
    margin: 0;
}

.summary-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

/* 库存图表 */
.inventory-chart {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-4);
}

.chart-container {
    position: relative;
}

.progress-ring {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-svg {
    transform: rotate(-90deg);
}

.progress-background {
    fill: none;
    stroke: var(--fill-tertiary);
    stroke-width: 8;
}

.progress-bar {
    fill: none;
    stroke: var(--apple-blue);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--transition-normal);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-percentage {
    font-size: var(--font-size-title-2);
    font-weight: var(--font-weight-bold);
    color: var(--apple-blue);
}

.progress-label {
    font-size: var(--font-size-caption-1);
    color: var(--label-secondary);
}

.inventory-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.breakdown-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.breakdown-color.success {
    background-color: var(--apple-green);
}

.breakdown-color.primary {
    background-color: var(--apple-blue);
}

.breakdown-color.secondary {
    background-color: var(--label-secondary);
}

.breakdown-label {
    flex: 1;
    font-size: var(--font-size-subhead);
    color: var(--label-secondary);
}

.breakdown-value {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
    color: var(--label-primary);
}

/* 库存调整表单 */
.adjustment-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.adjustment-form .form-group {
    margin-bottom: 0;
}

.adjustment-form .btn {
    margin-top: var(--spacing-2);
}

/* 分期管理 */
.schedule-inventory {
    max-width: none;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-6);
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.schedule-item {
    background-color: var(--system-background-secondary);
    border-radius: var(--radius-large);
    padding: var(--spacing-6);
    border: 1px solid var(--separator-non-opaque);
    display: flex;
    align-items: center;
    gap: var(--spacing-6);
    position: relative;
    transition: all var(--transition-fast);
}

.schedule-item:hover {
    box-shadow: var(--shadow-medium);
}

.schedule-item.active {
    border-color: var(--apple-blue);
    background-color: rgba(0, 122, 255, 0.05);
}

.schedule-info {
    display: flex;
    gap: var(--spacing-6);
    flex: 1;
}

.schedule-date {
    text-align: center;
    min-width: 100px;
}

.date-main {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
    color: var(--label-primary);
    margin-bottom: var(--spacing-1);
}

.date-day {
    font-size: var(--font-size-caption-1);
    color: var(--label-secondary);
}

.schedule-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.detail-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.detail-label {
    font-size: var(--font-size-subhead);
    color: var(--label-secondary);
    min-width: 80px;
}

.inline-input, .inline-select {
    width: 80px;
    padding: var(--spacing-1) var(--spacing-2);
    font-size: var(--font-size-subhead);
    border: 1px solid var(--separator-opaque);
    border-radius: var(--radius-small);
    background-color: var(--system-background);
}

.inline-select {
    width: 120px;
}

.schedule-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-2);
    min-width: 120px;
}

.progress-info {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-1);
}

.progress-current {
    font-size: var(--font-size-title-3);
    font-weight: var(--font-weight-bold);
    color: var(--label-primary);
}

.progress-separator {
    font-size: var(--font-size-body);
    color: var(--label-tertiary);
}

.progress-total {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
}

.progress-bar-container {
    width: 100%;
}

.progress-status {
    width: 100%;
    text-align: center;
}

.schedule-actions {
    position: absolute;
    top: var(--spacing-4);
    right: var(--spacing-4);
    display: flex;
    gap: var(--spacing-2);
}

/* 库存设置 */
.inventory-settings {
    max-width: none;
}

.settings-section {
    margin-bottom: var(--spacing-8);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-4);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-4);
    background-color: var(--system-background);
    border-radius: var(--radius-medium);
    border: 1px solid var(--separator-non-opaque);
}

.automation-settings .setting-item {
    align-items: flex-start;
}

.setting-info {
    flex: 1;
    margin-right: var(--spacing-4);
}

.setting-name {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-medium);
    color: var(--label-primary);
    margin-bottom: var(--spacing-1);
}

.setting-desc {
    font-size: var(--font-size-subhead);
    color: var(--label-secondary);
    line-height: 1.4;
}

.automation-settings {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.alert-settings {
    background-color: var(--system-background-secondary);
    border-radius: var(--radius-large);
    padding: var(--spacing-6);
}

.recipient-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
    margin-bottom: var(--spacing-4);
}

.recipient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-3);
    background-color: var(--system-background);
    border-radius: var(--radius-medium);
    border: 1px solid var(--separator-non-opaque);
}

.recipient-name {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-medium);
    color: var(--label-primary);
}

.recipient-email {
    font-size: var(--font-size-subhead);
    color: var(--label-secondary);
    margin-left: var(--spacing-2);
}

.checkbox-group {
    display: flex;
    gap: var(--spacing-4);
    flex-wrap: wrap;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--apple-blue);
}

.checkbox-label {
    font-size: var(--font-size-subhead);
    color: var(--label-primary);
}

/* 变更记录 */
.inventory-history {
    max-width: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-6);
}

.history-filters {
    display: flex;
    gap: var(--spacing-3);
}

.filter-select, .filter-date {
    min-width: 120px;
}

.history-timeline {
    position: relative;
    padding-left: var(--spacing-8);
}

.history-timeline:before {
    content: "";
    position: absolute;
    left: var(--spacing-4);
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--separator-opaque);
}

.timeline-item {
    position: relative;
    margin-bottom: var(--spacing-6);
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: calc(-1 * var(--spacing-8));
    top: var(--spacing-2);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--system-background);
    z-index: 1;
}

.timeline-marker.sale {
    background-color: var(--apple-blue);
}

.timeline-marker.manual {
    background-color: var(--apple-orange);
}

.timeline-marker.reserve {
    background-color: var(--apple-purple);
}

.timeline-marker.cancel {
    background-color: var(--apple-green);
}

.timeline-content {
    background-color: var(--system-background);
    border-radius: var(--radius-medium);
    padding: var(--spacing-4);
    border: 1px solid var(--separator-non-opaque);
    margin-left: var(--spacing-4);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-3);
}

.timeline-title {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
    color: var(--label-primary);
}

.timeline-time {
    font-size: var(--font-size-caption-1);
    color: var(--label-tertiary);
    font-family: var(--font-family-mono);
}

.timeline-details {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.change-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    font-size: var(--font-size-subhead);
}

.change-before {
    color: var(--label-secondary);
}

.change-info i {
    color: var(--label-tertiary);
}

.change-after {
    color: var(--apple-blue);
    font-weight: var(--font-weight-medium);
}

.change-reason {
    font-size: var(--font-size-subhead);
    color: var(--label-primary);
    line-height: 1.4;
}

.change-operator {
    font-size: var(--font-size-caption-1);
    color: var(--label-tertiary);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .inventory-modal {
        width: 95vw;
        max-height: 95vh;
    }
    
    .inventory-summary {
        grid-template-columns: 1fr;
    }
    
    .inventory-stats {
        grid-template-columns: repeat(4, 1fr);
        min-width: auto;
    }
    
    .schedule-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-4);
    }
    
    .schedule-info {
        flex-direction: column;
        gap: var(--spacing-4);
    }
    
    .schedule-progress {
        flex-direction: row;
        justify-content: space-between;
        min-width: auto;
    }
    
    .progress-bar-container {
        flex: 1;
        margin: 0 var(--spacing-4);
    }
    
    .schedule-actions {
        position: static;
        justify-content: center;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        flex-direction: column;
    }
    
    .history-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-1);
    }
    
    .change-info {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .tab-pane {
        padding: var(--spacing-4);
    }
    
    .inventory-overview {
        padding: var(--spacing-4);
    }
    
    .inventory-stats {
        grid-template-columns: 1fr 1fr;
    }
    
    .summary-card {
        padding: var(--spacing-4);
    }
    
    .schedule-details {
        gap: var(--spacing-3);
    }
    
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-2);
    }
    
    .detail-label {
        min-width: auto;
    }
    
    .inline-input, .inline-select {
        width: 100%;
    }
    
    .history-timeline {
        padding-left: var(--spacing-6);
    }
    
    .timeline-marker {
        left: calc(-1 * var(--spacing-6));
    }
    
    .timeline-content {
        margin-left: var(--spacing-2);
    }
}